const { MessageEmbed, Message, WebhookClient } = require('discord.js');

module.exports = {
  name: 'messageDelete',
  /**
   *
   * @param {Message} message
   */
  execute(message) {
    if (message.author.bot) return;

    const log = new MessageEmbed()
      .setColor('#36393f')
      .setDescription(
        `📕 A [message](${message.url}) by ${
          message.author.tag
        } was **deleted**.\n**Deleted message:**\n ${
          message.content ? message.content : 'None'
        }`.slice('0', '4096')
      )
      .setFooter({
        text: `Member: ${message.author.tag} | ID: ${message.author.id}`,
      });

    if (message.attachments.size >= 1) {
      log.addField(
        'Attachments:',
        `${message.attachments.map(a => a.url)}`,
        true
      );
    }
    new WebhookClient({
      url: 'https://discord.com/api/webhooks/983642008088367134/FZQCDumUdCW8A2YujqRGnrO30bBJkB3EAovVhTk8sxPk3NA8OtUasKg9ok3eaSyAuPAh',
    })
      .send({ embeds: [log] })
      .catch(err => console.log(err));
  },
};
